Fix parsing of 'with' inside streaming operator. #1504
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is picking up where we left off in #697. Mostly the strong suggestion there was to use lexer states which has to be explored here
The stream expression has an expression followed by an optional 'with' '[' array_range_expression ']'
(LRM 11.4.14)
There are a few other cases where an expression can be trailed with 'with',
with_constraint_block: there we expect an
identifier list in parenthesis after 'with'
similar with array methods with predicate
with '(' ...)
Since the parser with one look-ahead can't see beyond the 'with', it runs into a shift/reduce conflict
as it does not know if '(' or '[' is to follow.
Disambiguate that in the lexer by creating a
separate token TK_with__followed_by_bracket which is a TK_with, where the lexer already looked ahead and knows that it will be followed by '['.
After seeing the '[', everything but the "with" is put back into the stream to be processed separately.
Changed lexer and parser as well as associated unit tests including formatter.
Fixing #693